import { useRegions } from '@/composables/useRegions.ts'

export default function useConfig() {
  const { parse } = useLangField()
  const { allRegionOptions } = useRegions()

  const tableColumns = buildColumns([
    {
      title: '带宽类型',
      dataIndex: 'name',
      render({ record }) {
        const name = parse(record.name)
        if (!name) {
          return '-'
        }
        return name['zh-CN']
      },
    },
    {
      title: '类型英文名',
      dataIndex: 'name',
      render({ record }) {
        const name = parse(record.name)
        if (!name) {
          return '-'
        }
        return name.en
      },
    },
    {
      title: '所属区域',
      dataIndex: 'region_name',
      render({ record }) {
        return getOptionLabel(record.region_id, allRegionOptions.value)
      },
    },
    {
      title: '带宽值',
      dataIndex: 'value',
      render({ record }) {
        return `${record.value || 0} Mbps`
      },
    },
    {
      title: '创建时间',
      dataIndex: 'created_at',
      format: 'date-time',
    },
    {
      title: '操作',
      width: 90,
      cellClass: 'actions-cell',
      slotName: 'actions',
    },
  ])

  return {
    tableColumns,
  }
}
